// 04jyhs/accountAdmin/accountAdmin.js
var co = require('../../resource/js/common.js')
var app = getApp()
var _this, _data
Page({
   data: {
      change: '',
      UserType:''
   },
   onLoad: function (options) {
      _this = this
      _data = this.data
      _this.setData({
         UserType: app.Data.userInfo.User_Type
      })   
   },

   onShow: function () {
      _this.getNewBalance()
   },
   //获取最新余额
   getNewBalance() {
      _this.setData({
         change: ""
      })
      if (app.Data.shopInfo.Biz_ID == 91){ //企业的余额
         co.getJyhsApi("money/Recordbiz/getBalance", {
            Biz_ID: app.Data.shopInfo.Biz_ID
         }, function (res) {
            if (res.code == 0) {
               var bizMoney = parseFloat(res.data['Biz_Balance'])
               app.Data.shopInfo.Biz_Money = bizMoney
               _this.setData({
                  change: bizMoney
               })
            }
         })
      }else{
         co.getJyhsApi("money/Recorduser/getBalance",{
            User_ID: app.Data.userInfo.User_ID
         },function(res){
            if(res.code == 0){
               var UserMoney = parseFloat(res.data['User_Balance'])
               app.Data.userInfo.User_Balance = UserMoney
               _this.setData({
                  change: UserMoney
               })
            }
         })
      }
   },
   rechargeAndkiting: function (e) {
      var shop = app.Data.shopInfo
      var id = e.currentTarget.dataset.id
      if (shop.PayPassword_Is_Set == 0) {
         co.confirm('重要提示', '未设置支付密码', '取消', '前往设置', function (res) {
            if (res) {
               wx.navigateTo({
                  url: '/04jyhs/setting/accountNumber/accountNumber',
               })
            }
         })
         return
      }
      wx.navigateTo({
         url: id == 1 ? '/04jyhs/accountAdmin/rechange/rechange' : '/04jyhs/accountAdmin/withdrawals/withdrawals'
      })
   },
   
   //跳转到我的银行卡页面
   bankCard: function () {
      wx.navigateTo({
         url: '/04jyhs/accountAdmin/bankCard/bankCard',
      })
   },
})